package com.zcfeng.ischool;

import android.content.Intent;
import android.os.SystemClock;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import db.dao.ArticleDao;
import utils.MyConstaints;
import utils.SPUtils;
import utils.ThreadUtils;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        SPUtils.putBoolean(getApplicationContext(), MyConstaints.UPDATED, false);
        ThreadUtils.runInThread(new Runnable() {
            @Override
            public void run() {
                while(!SPUtils.getBoolean(getApplicationContext(), MyConstaints.UPDATED, false))
                {
                    SystemClock.sleep(2000);
                }

                Intent intent =new Intent(SplashActivity.this,LoginActivity.class);
                startActivity(intent);
                finish();
            }
        });
        ArticleDao.update(getApplicationContext());
    }
}
